
Partial Class Pages_Controls_ctlRegistrarSalida
    Inherits System.Web.UI.UserControl


    Protected Sub btnSeleccionar_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim valor As String = txtCodigoPersona.Text
        If Val(valor) <> 0 Then

            If optTipo.Value = 1 Then
                Call CargaPersonaDNI(txtCodigoPersona.Text)
            Else
                Call CargaPersona(Convert.ToInt32(txtCodigoPersona.Text))
            End If


        End If
    End Sub

    Private Sub CargaPersona(ByVal CodigoPersona As Integer)
        Dim objPersona As New BusinessLogic.crPersona
        Dim ds As BusinessEntity.CCPersona
        ds = objPersona.GetDatosPersonaPorCodigo(CodigoPersona)
        txtPersonaID.Text = ds.TBSOCESIPersonaID
        txtApellidoMaterno.Text = ds.ApellidoMaterno
        txtApellidoPaterno.Text = ds.ApellidoPaterno
        txtNombres.Text = ds.Nombres
        txtCodPersona.Text = ds.CodPersona
        txtNumeroDocumento.Text = ds.NroDocumento
        cmbTipoDocumento.Value = ds.TipoDocumento
        imgFoto.ImageUrl = IIf(ds.RutaFoto = "SF", "~/Pages/Content/ImagePreview.gif", ds.RutaFoto)
    End Sub

    Private Sub CargaPersonaDNI(ByVal DNI As String)
        Dim objPersona As New BusinessLogic.crPersona
        Dim ds As BusinessEntity.CCPersona
        ds = objPersona.GetDatosPersonaPorNroDocumento(DNI)
        txtPersonaID.Text = ds.TBSOCESIPersonaID
        txtApellidoMaterno.Text = ds.ApellidoMaterno
        txtApellidoPaterno.Text = ds.ApellidoPaterno
        txtNombres.Text = ds.Nombres
        txtCodPersona.Text = ds.CodPersona
        txtNumeroDocumento.Text = ds.NroDocumento
        cmbTipoDocumento.Value = ds.TipoDocumento
        imgFoto.ImageUrl = IIf(ds.RutaFoto = "SF", "~/UploadImages/ImagePreview.gif", ds.RutaFoto)
    End Sub

    Private Sub GrabaRegistroSalida()
        Dim objRegistrarEntrada As New BusinessLogic.crRegistroEntradaSalida
        Dim ds As New BusinessEntity.CCRegistroEntradaSalida


        Try
            ds.PersonaID = txtPersonaID.Text
            ds.Observacion = Me.txtObservacion.Text
            ds.TitularID = 0
            If objRegistrarEntrada.GrabarRegistroDeSalida(ds) Then
                lblMensaje.Visible = True
                lblMensaje.Text = "Grabo..."
                Response.Redirect("~/Pages/frmRegistrarSalida.aspx")


            Else
                lblMensaje.Visible = True
                lblMensaje.Text = "No Grabo"
            End If


        Catch ex As System.IO.FileNotFoundException
            lblMensaje.Visible = True
            lblMensaje.Text = "No Grabo" 'ex.Message


        Catch ex As Exception

            lblMensaje.Visible = True
            lblMensaje.Text = "No Grabo" 'ex.Message

        End Try
    End Sub

    Protected Sub btnGrabar_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Call GrabaRegistroSalida()
    End Sub
End Class
